﻿@using Test.Utility.Extensions
@{
    var adminSession = ViewBag.AdminSession as Test.Web.Models.Sessions.AdminSession;
    var menuItems = adminSession.MenuItems;

    string controllerName = ViewContext.RouteData.Values["Controller"].ToString();
    string actionName = ViewContext.RouteData.Values["Action"].ToString();

    var currentMenu = menuItems.FirstOrDefault(m => m.Controller.EqualsNoCase(controllerName) && m.Action.EqualsNoCase(actionName));
    if (currentMenu.IsNotNull())
    {
        actionName = currentMenu.MenuItemName;
    }

    string currentName = ViewBag.CurrentName ?? actionName;
    string parentName = ViewBag.ParentName;
    string parentUrl = ViewBag.ParentUrl;
}

<ul class="page-breadcrumb breadcrumb">
    <li>
        <i class="fa fa-home"></i>
        @Html.ActionLink("首页", "Index", "Home")
        <i class="fa fa-angle-right"></i>
    </li>
    @if (parentName.IsNotNullAndNotWhiteSpace())
    {
        <li>
            @if (parentUrl.IsNullOrWhiteSpace())
            {
                @parentName
            }
            else
            {
                <a href="@parentUrl">@parentName</a>
            }
            <i class="fa fa-angle-right"></i>
        </li>
    }
    <li>
        @currentName
    </li>
</ul>